package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;
import android.view.View;
import com.bjesc_b2c.app.appraiset.R;
import com.bjesc_b2c.app.appraiset.bean.WaitCheckCarBean;
import com.example.codeutils.utils.TimeUtils;
import java.util.List;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;

/**
 * Created by yidong on 2017/8/2.
 */

public class DealerWaitCheckAdapter extends CommonAdapter<WaitCheckCarBean.CarsBean> {
    public DealerWaitCheckAdapter(Context context, int layoutId, List<WaitCheckCarBean.CarsBean> datas) {
        super(context, layoutId, datas);
    }

    private operateListener listener;
    private int type;
    public void setListener(operateListener listener) {
        this.listener = listener;
    }
    public void setType(int type){
        this.type = type;
    }
    @Override
    protected void convertView(ViewHolder holder, WaitCheckCarBean.CarsBean bean, final int position) {
        holder.setText(R.id.tv_car_type, bean.getCar_name());
        holder.setText(R.id.tv_car_vin, bean.getVin_number());
        holder.setText(R.id.tv_from_to, bean.getExamines_nickname());
        holder.setText(R.id.tv_create_time, TimeUtils.millis2String(bean.getTrack_time()));
        if (type == 1) {
            holder.setText(R.id.tv_off_status, "检测车源");
        } else {
            holder.setText(R.id.tv_off_status, "确认正常");
        }
        holder.setOnClickListener(R.id.tv_off_status, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.detectionCar(position,type);
                }
            }
        });
        holder.setOnClickListener(R.id.tv_adjustment_status, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.adjustmentCar(position);
                }
            }
        });
    }

    public interface operateListener {
        void adjustmentCar(int position);
        void detectionCar(int position, int type);
    }
}

